const express = require('express');
const router = express.Router();

const data = require('./data');

//10086  到下一个10086间的是我修改的内容
const mysql = require('mysql')
const accountSQL = require('../db/accountSQL');
const appealSQL = require('../db/appealSQL');
const dbConfig = require('../db/dbConfig');
const managerSQL = require('../db/managerSQL');
const messageSQL = require('../db/messageSQL');
const replySQL = require('../db/replySQL');
const sectionSQL = require('../db/sectionSQL');
const topicSQL = require('../db/topicSQL');
const userSQL = require('../db/userSQL');


// 使用DBConfig.js的配置信息创建一个MySql链接池
var pool = mysql.createPool( dbConfig.mysql )
// 响应一个JSON数据
const responseJSON = function (res, ret) {
  if (typeof ret === 'undefined') {
    res.json({
      code: '-200',
      msg: '操作失败'
    })
  } else {
    res.json(ret)
  }
}
//10086

router.get('/getinfo', (req, res) => {
  pool.getConnection(function (err,connection) {
    let {userID} = req.query;
    // 检查分区是否为空
    if (!userID
      || typeof userID != "string"
      || !userID.length) {
      res.json({
        err: 1,
        message: '用户ID为空'
      })
    } else {
      // 下方改数据库操作代码
      res.json({
        err: 200,
        userID: 1,
        userName: "aaa",
        userGender: "秀吉",
        userAge: "17",
        userLevel: 1,
        userTime: 19700101,
        userProfile: "秀吉的性别就是秀吉"
      })
    }
  })
})

module.exports = router;
